#include "BaseConn.h"

BaseConn::BaseConn()

{
	m_pMysql = NULL;
	m_pMysql =mysql_init(m_pMysql);
	if(NULL ==m_pMysql)
	{
		LOG4CPLUS_ERROR(m_log.LogGet(), "mysql_init(m_pMysql) failure");
		exit(0);
	}
		
	int nRetNote =0;
	nRetNote =mysql_options(m_pMysql,MYSQL_OPT_COMPRESS,0);
	if(0 !=nRetNote)
	{
		LOG4CPLUS_ERROR(m_log.LogGet(), "mysql_options(m_pMysql,MYSQL_OPT_COMPRESS) failure");
		exit(0);
	}
	
	nRetNote =mysql_options(m_pMysql,MYSQL_READ_DEFAULT_GROUP,"odbc");
	if(0 !=nRetNote)
	{
		LOG4CPLUS_ERROR(m_log.LogGet(), "mysql_options(m_pMysql,MYSQL_OPT_COMPRESS) failure");
		exit(0);
	}


	if (!mysql_real_connect(m_pMysql,NULL,"root","love5228","test",0,NULL,0))
	{
		LOG4CPLUS_ERROR(m_log.LogGet(), "mysql_real_connect failure");
		exit(0);
	}


	nRetNote =mysql_query(m_pMysql,"set names utf8");
	if(0 !=nRetNote)
	{
		LOG4CPLUS_ERROR(m_log.LogGet(), "mysql_qurey(m_pMysql,set names utf8)  failure");
		exit(0);
	}
}

MYSQL_STMT*	BaseConn::StmtInit()
{
	return  mysql_stmt_init(m_pMysql);
}

BaseConn::~BaseConn()
{
	mysql_close(m_pMysql);	
}
